package com.example.myapplication.navigation;

import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;

import com.example.myapplication.databinding.ActivityFragmentEnterBinding;
import com.example.myapplication.utils.NameCreator;


/**
 * Created by xiaolong on 2021/12/6 9:18 下午
 * email：xinxiaolong123@foxmail.com
 */
public class FragmentEnterActivity extends AppCompatActivity {

    ActivityFragmentEnterBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding=ActivityFragmentEnterBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

//        //可以这种方式动态绑定 graph
//        NavHostFragment navHostFragment = (NavHostFragment)getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
//        NavController navController = navHostFragment.getNavController();
//        navController.setGraph(R.navigation.revover_graph);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode==KeyEvent.KEYCODE_BACK){
            Log.e("fragment_lifecycle","###################################点击了返回键###################################");
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        NameCreator.getInstance().clear();
    }
}
